home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-03-14 | 5.1 KB | 123 lines | [TEXT/KAHL] |
- Using the ProgressClass
-
- • Remember to set the flag in your size resource to allow for background processing!
-
- • What files you should include:
- nclude ProgressClass.cp, ChiselClass.cp and Environ.cp in your project
- include "ProgressClass.h" wherever you need to create a ProgressClass variable
-
- • Options
- Available options to choose from with the SetOptions command:
-
- default options: User can cancel, the progress bar's frame is chiseled in, the progress
- bar is chiseled, there is a generic gray background to the window, and
- a fine chisel surrounds the bar's frame
-
- (Add or subtract these to add or remove; for example for all default options except
- "fineChisel" type var.SetOptions(progressDefaults-fineChisel)
-
- void SetOptions(short options=progressDefaults);
-
- progressDefaults // turns on all defaults
- canCancel // toggles whether user can cancel the operation
- chiselFrame // will chisel the progress bar's frame
- grayBack // gray background for progress window? Note: you can specify your
- // own window color via SetWindowColor
- chiselBar // will chisel the progress bar out if chosen
- fineChisel // outlines the whole chisel frame with a fine chisel
-
-
- When declaring your variable, you can set the options (note the default options are passed if
- you don't specify any):
-
- ProgressClass(short options=progressDefaults);
-
- • Configuring the ProgressClass
-
- While you don't technically need to do anything except declare an instance of the ProgressClass
- and show the window, you should give it some information so that it can work like a truly
- integrated part.
-
- • Menu IDs
- Because it can handle all events received, letting you concentrate on coding your task,
- you should pass it the ID number of the apple menu as well as your other menus so that it can
- handle mouse down events effectively. It will dim all of your menus if they are selected,
- but allow items from the apple menu to be selected (except your about box - it will search until
- it finds the line dividing your about box and any other items you have and only launch items in
- the apple menu). I have allowed for eight of your menus to be set in the class and dimmed. If
- you don't pass the IDs of your menus, they will not be deselected when the user clicks in the
- menu bar. All items will be returned to their previous state when either a) you hide the window
- or b) the variable is destroyed
-
- void SetAppleMenu(short appleID);
- void AddMenuNumber(short m1=0, short m2=0, short m3=0, short m4=0, short m5=0, short m6=0, short m7=0, short m8=0);
-
- • You can also change the progress bar's height (from its default 11 pixels), its width,
- its color, and the empty color (the color behind the bar).
-
- void SetBarHeight(short height);
- void SetBarWidth(short width);
-
- void SetEmptyColor(RGBColor theColor);
- void SetBarColor(RGBColor theColor);
-
- • You can choose a different background color for the window.
-
- void SetWindowColor(RGBColor theColor);
-
- • You should name the progress window and pass the class a string to post over the progress
- bar (for example, "Sorting List…")
-
- void SetTexts(Str255 windowTitle, Str255 paramText);
-
- • Finally, you can pass the resource ID of a custom button control to the class to use
- instead of the Mac's default button
-
- void SetControlID(short controlID);
-
-
-
- • Controlling the Length of the Progress Bar
-
- To control the length of the progress bar, you can either set the minimum and maximum
- values you will be using throughout your operation (if you're in a for loop, for example)
- and pass the current value to SetBar, or you can pass a floating point value representing
- what percent you have completed. You can also update the string above the progress bar
- when you update the value of the bar.
-
- void SetMinMax(short min, short max);
- void SetBar(short current);
- void SetBar(short current, Str255 paramText);
- void SetBar(float current);
- void SetBar(float current, Str255 paramText);
-
-
- • Receiving Events
-
- To make life easy on you, most events can be handled by the ProgressClass if you call the
- ReceivedEvent(…) function on a regular basis. Calling this function will allow the class
- to update itself (so it should therefore be called at least once after you call ShowBarWindow())
- and will inform you if you need to update/deactivate windows and whether the user cancelled or
- not. If ReceivedEvent(…) returns true, then you should examine its parameters. Here's how
- each event will be returned:
-
- UpdateEvents:
- userCancel=0, deactivate=0, updateWindow=WindowPtr of window to be updated
- ActivateEvents:
- deactivate:
- userCancel=0, deactivate=1, updateWindow=WindowPtr of window to be deactivated
- User Cancelled:
- userCancel=1, deactivate=0, updateWindow=nil
-
- Boolean ReceivedEvent(Boolean *userCancel, Boolean *deactivate, WindowPtr *updateWindow);
-
-
- • Hiding and showing windows
-
- void HideBarWindow();
- void ShowBarWindow();
-
-
- • If you have any other needs or desires for this class, or if you find bugs, please contact me
- at MaT101@aol.com. Also, if you can tell me how to get a hold of the hilite color in the qd global
- var, let me know!